<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
	date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
	$usuario = $_SESSION['name'];
	$fecha = date("Y-m-d H:i:s");
	$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Cambio de cargo del personal' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}

$Cedula=$_GET['Cedula'];
if ($Cedula){
	$buscar = mysql_fetch_array(mysql_query("SELECT Cargo FROM personal WHERE CI_p='$Cedula' "));
	if($buscar[0] == 'Administrativo'){
		$sql = mysql_query("SELECT administrativo.*, personal.Nombres, personal.Apellidos FROM administrativo INNER JOIN personal ON administrativo.CI_p=personal.CI_p WHERE personal.CI_p='$Cedula' ");
	}else if($buscar[0] == 'Docente'){
		$sql = mysql_query("SELECT docente.CI_p, 'Docente', docente.Periodo, personal.Nombres, personal.Apellidos FROM docente INNER JOIN personal ON docente.CI_p=personal.CI_p WHERE personal.CI_p='$Cedula' ");
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cambio de Cargo</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script> 
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});
</script>
<script>
function cargo(car){ 
	if(car=="Docente"){
		document.getElementById('administrativo').style.display="none";
	}else if(car=="Administrativo"){
		document.getElementById('administrativo').style.display="inline";
	}else if(car==""){
		document.getElementById('administrativo').style.display="none";
	}
}
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">
<form name='FormCambioCargo' action='CambioCargo.php' method='GET'>
<script language="JavaScript1.2"> 
function verifyInput(_selList,_textBox) {
	document.getElementById('Cedula').readOnly = false;
	var SI = eval(_selList+".selectedIndex");
	var SV = eval(_selList+".options[SI].value");
	eval(_textBox+".value = SV");
	var a = eval(_selList+".options.selectedIndex=0");
	document.FormCambioCargo.Cedula.focus()
}
</script>
<blockquote><h2 align="center">CAMBIO DE CARGO</h2></blockquote>
			<fieldset>
			<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
			<table width=100% cellspacing=5 cellpadding=0 border=0>
			<tr>
				<td align="center">C&eacute;dula de Identidad: <select name="Nac" onchange="verifyInput('document.FormCambioCargo.Nac','document.FormCambioCargo.Cedula')"><option></option><option>V-</option><option>E-</option></select><input type=text name="Cedula" id="Cedula" size=11 maxLength=10 readonly>
				&nbsp;<input class=button type=submit value=Buscar></td>
			</tr>
			<tr><td align=center><label> Ej: V-12345678</label></td></tr>
			</table>
			</fieldset>
</form>
<div class="post">
<span></span></div>

	<?php if ($sql){
		echo "<form ACTION='ResCambioCargo.php' METHOD='POST'>";
		echo "<fieldset>";
		echo "<legend align=left><b><font size=2>PERSONAL</font></b></legend>";
		echo "<table width=100%  cellspacing=5 cellpadding=0 border=0>";
			while($row=mysql_fetch_array($sql)){
				echo "<tr>";
				echo "<td width=50%>C&eacute;dula de Identidad: </td><td>$row[0]</td>";
				echo "<input type=hidden name=Cedula value='$row[0]'>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Nombres: </td><td>$row[3]</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Apellidos: </td><td>$row[4]</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Periodo trabajado: </td><td>$row[2]</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Cargo: </td><td>$row[1]</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Periodo nuevo: </td><td>"; if(date(m)>=8){ $anio=date(Y); $anio2=$anio+1; echo "$anio - $anio2 <input type=hidden name=Periodo value='$anio - $anio2'>"; } else{ $anio=date(Y)-1; $anio2=$anio+1; echo "$anio - $anio2 <input type=hidden name=Periodo value='$anio - $anio2'>"; } echo "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>Nuevo cargo: </td><td><select name=Cargo id=Cargo onChange=\"cargo(this.value)\"><option></option><option>Docente</option><option>Administrativo</option></select><select name=administrativo id=administrativo style=\"display: none;\"><option></option>
																																																									<option>Director(a)</option>
																																																									<option>Sub-director(a) Acad.</option>
																																																									<option>Sub-director(a) Admin.</option>
																																																									<option>Secretaria</option></select></td>";
				echo "</tr>";
			}
		echo "</table>";
		echo "</fieldset>";

		echo "<div class=post>";
		echo "<span></span></div>";
		
		echo "<div name=botonera align=center>";
		echo "<input class=button type=Submit value=Guardar> <input class=button type=button value=Cancelar onClick=\"location='index.php'\">";
		echo "</div>";
		echo "</form>";
	} ?>

<div align=right><br><a title='Ayuda' href="Manuales/ManualUsuario_2.5.pdf" onclick="window.open(this.href,'Manual','params'); return false"><img src='images/help.png' width=8% height=15%></a></div>

</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
